<?php
class QEF_Widget extends WP_Widget
{
    function __construct()
    {
        parent::WP_Widget('QEF_Widget', 'Quick Enquiry Form');
    }

    function widget($arg, $instance)
    {
        $title = apply_filters('widget_title', _trans('qef.title.frm_title'));
        echo $arg['before_widget'];
        if (empty($title)) {
            $title = $arg['widget_name'];
        }
        echo $arg['before_title'] . $title . $arg['after_title'];
        include_once (__dir__ . '/quick_enquiry_form.html.php');
        echo $arg['after_widget'];
    }

    function form($instance)
    {
        $title = isset($instance['title']) ? $instance['title'] : __('New title', 'text_domain'); ?>
        <p>
            <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget title:'); ?></label> 
            <input class="widefat" 
                type="text" 
                id="<?php echo $this->get_field_id('title'); ?>" 
                name="<?php echo $this->get_field_name('title'); ?>" 
                value="<?php echo esc_attr($title); ?>" />
        </p> <?php
    }

    function update($new_instance, $old_instance)
    {
        $instance = $old_instance;
        $instance['title'] = strip_tags($new_instance['title']);
        if (current_user_can('unfiltered_html'))
            $instance['text'] = $new_instance['text'];
        else
            $instance['text'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['text'])));
        return $instance;
    }
}
?>